String.prototype.cnLength = function(){
	return this.replace(/[^\x00-\xff]/g, "**").length;
}

String.prototype.trim = function() {
  return this.replace(/(^\s*)|(\s*$)/g, "");
}

String.prototype.replaceBR = function() {
	return this.replace(/\r\n/g, "<br>");
}
String.prototype.replaceAll = function(s1,s2) {
	return this.replace(new RegExp(s1,"gm"),s2); 
}

//
String.prototype.toObject = function(){
	return eval('('+this+')');
}



var toString = function(o){
	var r = [];
    if(typeof o =="string") return "\""+o.replace(/([\'\"\\])/g,"\\$1").replace(/(\n)/g,"\\n").replace(/(\r)/g,"\\r").replace(/(\t)/g,"\\t")+"\"";
    if(typeof o =="undefined") return "undefined";
    if(typeof o == "object"){
        if(o===null) return "null";
        else if(!o.sort){
            for(var i in o)
                r.push(i+":"+toString(o[i]))
            r="{"+r.join()+"}"
        }else{
            for(var i =0;i<o.length;i++)
                r.push(toString(o[i]))
            r="["+r.join()+"]"
        }
        return r;
    }
    return o.toString();
}